package org.tigris.scarab.model;

import java.io.Serializable;
import java.util.Date;

/**
 * History of changes made to the attributes of an issue.
 * @composed 1 - 1 Issue 
 */
public class Activity implements Serializable {

    private Long activityId; //SCARAB_ACTIVITY.ACTIVITY_ID
    private Issue issue; //FK SCARAB_ACTIVITY.ISSUE_ID
    private Integer attributeId; //SCARAB_ACTIVITY.ATTRIBUTE_ID
    private Transaction transaction; //SCARAB_ACTIVITY.TRANSACTION_ID
    private Integer oldNumericValue; //SCARAB_ACTIVITY.OLD_NUMERIC_VALUE
    private Integer newNumericValue; //SCARAB_ACTIVITY.NEW_NUMERIC_VALUE
    private Integer oldUserId; //SCARAB_ACTIVITY.OLD_USER_ID
    private Integer newUserId; //SCARAB_ACTIVITY.NEW_USER_ID
    private Integer oldOptionId; //SCARAB_ACTIVITY.OLD_OPTION_ID
    private Integer newOptionId; //SCARAB_ACTIVITY.NEW_OPTION_ID
    private String oldValue; //SCARAB_ACTIVITY.OLD_VALUE
    private String newValue; //SCARAB_ACTIVITY.NEW_VALUE
    private Integer dependId; //SCARAB_ACTIVITY.DEPEND_ID
    private String description; //SCARAB_ACTIVITY.DESCRIPTION
    private Date endDate; //SCARAB_ACTIVITY.END_DATE
    private Long attachmentId; //SCARAB_ACTIVITY.ATTACHMENT_ID
    private ActivityTypeEnum activityType; //mapped by SCARAB_ACTIVITY.ACTIVITY_TYPE

    public Activity() {
    }

    public Long getActivityId() {
        return activityId;
    }

    /**
     * @return the Issue bound to this Activity if exists, else null.
     */
    public Issue getIssue() {
        return issue;
    }

    public Integer getAttributeId() {
        return attributeId;
    }

    public void setAttributeId(Integer attributeId) {
        this.attributeId = attributeId;
    }

    public Transaction getTransaction() {
        return transaction;
    }

    public Integer getOldNumericValue() {
        return oldNumericValue;
    }

    public void setOldNumericValue(Integer oldNumericValue) {
        this.oldNumericValue = oldNumericValue;
    }

    public Integer getNewNumericValue() {
        return newNumericValue;
    }

    public void setNewNumericValue(Integer newNumericValue) {
        this.newNumericValue = newNumericValue;
    }

    public Integer getOldUserId() {
        return oldUserId;
    }

    public void setOldUserId(Integer oldUserId) {
        this.oldUserId = oldUserId;
    }

    public Integer getNewUserId() {
        return newUserId;
    }

    public void setNewUserId(Integer newUserId) {
        this.newUserId = newUserId;
    }

    public Integer getOldOptionId() {
        return oldOptionId;
    }

    public void setOldOptionId(Integer oldOptionId) {
        this.oldOptionId = oldOptionId;
    }

    public Integer getNewOptionId() {
        return newOptionId;
    }

    public void setNewOptionId(Integer newOptionId) {
        this.newOptionId = newOptionId;
    }

    public String getOldValue() {
        return oldValue;
    }

    public void setOldValue(String oldValue) {
        this.oldValue = oldValue == null ? null : oldValue.trim();
    }

    public String getNewValue() {
        return newValue;
    }

    public void setNewValue(String newValue) {
        this.newValue = newValue == null ? null : newValue.trim();
    }

    public Integer getDependId() {
        return dependId;
    }

    public void setDependId(Integer dependId) {
        this.dependId = dependId;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description == null ? null : description.trim();
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public Long getAttachmentId() {
        return attachmentId;
    }

    public void setAttachmentId(Long attachmentId) {
        this.attachmentId = attachmentId;
    }

    public ActivityTypeEnum getActivityType() {
        return activityType;
    }

    public void setActivityType(ActivityTypeEnum activityType) {
        this.activityType = activityType;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Activity other = (Activity) obj;
        if (this.activityId != other.activityId && (this.activityId == null || !this.activityId.equals(other.activityId))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 97 * hash + (this.activityId != null ? this.activityId.hashCode() : 0);
        return hash;
    }
}